﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace commonImportPlugin
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public int sort(string str1,string str2)
        {
            if (str1.Split('&')[0].CompareTo(str2.Split('&')[0]) >= 0)
                return 1;
            else
                return 0;
        }
        struct test
        {
            public string a { set; get; }
            public string b { set; get; }
        }

        private void buttonTest_Click(object sender, EventArgs e)
        {
            //Test t = new Test();
            //t.Show();

        }
        private bool isNunumberString(string numberString)
        {
            Regex rgx = new Regex(@"^\d+$");
            if(rgx.IsMatch(numberString))          
                return true;
            else
                return false;
            
        }
        public static List<Student> GetStudents()
        {
            // Use a collection initializer to create the data source. Note that each element
            //  in the list contains an inner sequence of scores.
            List<Student> students = new List<Student>
            {
                new Student {First="东瓜林长田", Last="1", ID=111},
                new Student {First="老熊箐", Last="1", ID=111},
                new Student {First="东瓜林", Last="1", ID=111},
                new Student {First="大得勒", Last="1", ID=111},
                new Student {First="长田", Last="1", ID=111} 
            };

            return students;

        }


        #region 结构体
        struct PBOCData
        {
            public string bankCardId;
            public string filePath ;
        }
        struct SSData
        {
            public string bankCardId ;
            public string filePath ;
        }
        #endregion

        #region 排序测试结构体
        public class Student
        {
            public string First { get; set; }
            public string Last { get; set; }
            public int ID { get; set; }
        }

        public struct sortStruct
        {
            public int index;
            public int age;
            public string bankCardId;
            public string filePath;
        }
        #endregion

        #region 筛选函数
        List<PBOCData> filterDatas(List<PBOCData> pbocDatas,List<SSData> SSDatas)
        {
            List<PBOCData> result =new List<PBOCData>();
           result= pbocDatas.FindAll(delegate(PBOCData data)
            {
                foreach (SSData ssData in SSDatas)
                {
                    if (ssData.bankCardId == data.bankCardId)
                    {                       
                        SSDatas.Remove(ssData);
                        return true;
                    }
                    
                }
                return false;
                
            });
           return result;
        }
        #endregion

        #region 排序函数
        public int  sort(sortStruct Data1, sortStruct Data2)
        {         
            if (Data1.index != Data2.index)
                return Data1.index.CompareTo(Data2.index);
            else if (Data1.age != Data2.age)
                return Data1.age.CompareTo(Data2.age);
            else 
                return Data1.bankCardId.CompareTo(Data2.bankCardId);           
        }
        #endregion

        #region 泛型方法
        static void Swap<T>(ref T lhs, ref T rhs)
        {
            T temp;
            temp = lhs;
            lhs = rhs;
            rhs = temp;
        }
        #endregion

    }
}
